package com.sskj.givecoin.v.activity;

import android.content.Context;
import android.content.Intent;
import android.widget.ImageView;
import android.widget.TextView;

import com.sskj.givecoin.R;
import com.sskj.givecoin.common.App;
import com.sskj.givecoin.common.widget.ToolBarLayout;
import com.sskj.givecoin.m.bean.ShareEntry;
import com.sskj.givecoin.p.activity.MyFriendsActivity;
import com.sskj.givecoin.p.activity.MySharePresenter;
import com.sskj.givecoin.utils.APKVersionCodeUtils;
import com.sskj.givecoin.utils.ClickUtil;
import com.sskj.givecoin.v.base.BaseActivity;

import butterknife.BindView;

public class MyShareActivity extends BaseActivity<MySharePresenter> {
    @BindView(R.id.toolbar)
    ToolBarLayout toolbar;
    @BindView(R.id.share_count)
    TextView shareCount;
    @BindView(R.id.share_get)
    TextView shareGet;
    @BindView(R.id.tv_friends)
    TextView tvFriends;
    @BindView(R.id.tv_go_share)
    TextView tvGoShare;
    @BindView(R.id.tv_get_detail)
    TextView tvGetDetail;
    @BindView(R.id.rules)
    TextView rules;
    @BindView(R.id.service)
    TextView service;
    @BindView(R.id.version)
    TextView version;
    @BindView(R.id.facebook)
    ImageView facebook;
    @BindView(R.id.twitter)
    ImageView twitter;
    @BindView(R.id.github)
    ImageView github;

    @Override
    public MySharePresenter getPresenter() {
        return new MySharePresenter();
    }

    @Override
    public void initView() {
        toolbar.setLeftButtonOnClickLinster(v -> finish());
        ClickUtil.click(tvFriends, () -> MyFriendsActivity.start(this));
        ClickUtil.click(tvGoShare, () -> startActivity(new Intent(this, ShareActivity.class)));
        ClickUtil.click(tvGetDetail, () -> CommonDetail.start(this, 3));  // 推荐
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_my_share;
    }

    @Override
    public void initData() {
        mPresenter.getData(1);
        initFooter();
    }

    public static void start(Context context) {
        Intent intent = new Intent(context, MyShareActivity.class);
        context.startActivity(intent);
    }

    public void setData(ShareEntry data) {
        setText(shareCount, data.getTtl());
        setText(shareGet, data.getForce());
    }


    public void initFooter() {
        setText(version, App.INSTANCE.getString(R.string.current_version) + APKVersionCodeUtils.getVerName(this));
        ClickUtil.click(rules, () -> WebViewActivity.start(this, "trans_agree"));
        ClickUtil.click(service, () -> WebViewActivity.start(this, "reg_agree"));
//        ClickUtil.click(facebook, () -> WebViewActivity.start(this, "facebook"));
//        ClickUtil.click(github, () -> WebViewActivity.start(this, "github"));
//        ClickUtil.click(twitter, () -> WebViewActivity.start(this, "twitter"));
    }

}